package com.yzmdxt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 张桂州
 * @create 2017-07-19 14:06
 **/
@RestController
public class DcController {

    @Autowired
    DiscoveryClient client;

    @GetMapping("/dc")
    public String dc(){
        String services = "Services:"+client.getServices();
        System.out.println(services);
        return services;
    }

    @GetMapping("/test")
    public Result test(){
        String services = "Services:"+client.getServices();
        Result<List> result = new Result<List>();
        result.setCode(0);
        result.setMessage("success");
        List list = new ArrayList();

        for (int i = 0; i < 5; i++) {
            Map<String,String>  map = new HashMap<String, String>();
            map.put("name","aa"+i);
            map.put("dec","这是测试数据"+i);
            list.add(map);

        }

        result.setData(list);

        return result;
    }
}
